{% extends "base.html" %}

{% block sreach %}
 <form method='GET' action='' class="navbar-form navbar-left" role="search">
        <div class="form-group">
          <input type="text" name='q' class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">搜索</button>
      </form>
{% endblock %}


{% block content %}
{% for i in stuff_list %}
  <div class="col-sm-6 col-md-4">
    <div class="thumbnail">
      {% if i.image %}
      <img src="{{ i.image.url }}" class="img-responsive" alt="img-responsive">
      {% endif %}
      <div class="caption">
        <h3>{{ i.name }}</h3>
        <p>价格：{{ i.price }}元 | 类别：{{ i.category }}</p>
        <p>描述：{{ i.description }}</p>
        <p>发布时间：{{ i.timestamp }}</p>
        <p>发布者：{{ i.user }}</p>
        <p class="text-right" ><a href="{% url 'detail' id=i.id %}">查看详情</a></p>
      </div>
    </div>
  </div>
{% endfor %}

<div class="pagination">
    <span class="step-links">
        {% if stuff_list.has_previous %}
            <a href="?page={{ stuff_list.previous_page_number }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}">previous</a>
        {% endif %}

        <span class="current">
            Page {{ stuff_list.number }} of {{ stuff_list.paginator.num_pages }}.
        </span>

        {% if stuff_list.has_next %}
            <a href="?page={{ stuff_list.next_page_number }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}">next</a>
        {% endif %}
    </span>
</div>

{% endblock %}